<template>
  <div class="partnerList">
    <div class="partnerList_top">
      <div class="into_index">首页<i class="el-icon-close"></i></div>
      <div class="current">创客提现<i class="el-icon-close"></i></div>
    </div>
    <div class="partnerList_bottom">
      <div class="partnerList_bottom_new">
        <div class="partnerList_bottom_new_goods">
          <div class="partnerList_bottom_new_goods_btn">
            <el-date-picker
              @change="selectTime"
              v-model="valueTime"
              type="daterange"
              :picker-options="pickerOptions"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            >
            </el-date-picker>
            <!-- <button @click="addRecommend"><i class="el-icon-trophy"></i>新增小区</button> -->
          </div>
          <div class="partnerList_bottom_new_goods_screening">
            <div class="regionSelect">
              订单类型
              <el-select
                v-model="valueType"
                @change="selectType"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
              <el-button type="primary" @click="exportFileFn"
                >导出 <i class="el-icon-download"></i
              ></el-button>
            </div>
            <div class="partnerList_bottom_new_goods_screening_right">
              <el-input v-model="input" placeholder="请输入"></el-input>
              <button @click="handerSeach">
                <i class="el-icon-search"></i>搜索
              </button>
            </div>
          </div>
        </div>
      </div>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="待审批" name="1">
          <tab-list
            ref="needFn"
            :thItem="thItem"
            :tabsNum="activeName"
            :keyword="input"
          ></tab-list>
        </el-tab-pane>
        <el-tab-pane label="审批通过" name="2">
          <tab-list
            ref="passFn"
            :thItem="thItem"
            :tabsNum="activeName"
            :keyword="input"
          ></tab-list>
        </el-tab-pane>
        <el-tab-pane label="被驳回" name="3">
          <tab-list
            ref="notFn"
            :thItem="thItem"
            :tabsNum="activeName"
            :keyword="input"
          ></tab-list>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script>
import tabList from "@/components/financeManage/withdrawal/makerApproval/tablePublic/tablePublic.vue";
export default {
  components: {
    tabList,
  },
  data() {
    return {
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now() - 8.64e6;
        },
      },
      cateList: [],
      cate: {},
      input: "",
      checkAll: false,
      page: 1,
      pageSize: 10,
      total: 0,
      checkBoxAll: [], // 选中的数据
      shelvesAlls: [],
      tableList: [],
      changeFn1: true,
      options: [
        {
          //订单类型列表
          label: "全部",
          value: 4,
        },
        {
          label: "创业主",
          value: 5,
        },
        {
          label: "创业精英",
          value: 6,
        },
      ],
      valueType: 4, //订单类型
      activeName: "1",
      valueTime: [],
      startDate: "",
      endDate: "",
      thItem: [
        "提现订单号",
        "提现到账类型",
        "银行名称",
        "银行卡号",
        "用户手机",
        "提现总额",
        "申请金额",
        "申请手续费",
        '代付结果',
        '失败原因'
      ],
      // thItem:['合作商类型','合作商名称','提现时间','提现金额','提现银行','银行卡号']
    };
  },
  created() {},
  mounted() {
    // this.getEstateList()

    this.$refs.needFn.getNeedList();
  },

  methods: {
    // 获取小区列表

    // 选择订单类型
    selectType(e) {
      if (this.activeName == "1") {
        this.$refs.needFn.getNeedList(e, 0, this.startDate, this.endDate);
      } else if (this.activeName == "2") {
        this.$refs.passFn.getNeedList(e, 1, this.startDate, this.endDate);
      } else {
        this.$refs.notFn.getNeedList(e, 2, this.startDate, this.endDate);
      }
    },

    // 导出按钮
    exportFileFn() {
      if (this.activeName == "1") {
        this.$refs.needFn.getNeedList(
          this.valueType,
          0,
          this.startDate,
          this.endDate,
          1
        );
      } else if (this.activeName == "2") {
        this.$refs.passFn.getNeedList(
          this.valueType,
          1,
          this.startDate,
          this.endDate,
          1
        );
      } else {
        this.$refs.notFn.getNeedList(
          this.valueTypee,
          2,
          this.startDate,
          this.endDate,
          1
        );
      }
    },

    // tabs切换
    handleClick(e) {
      console.log(e, "tabs");
      if (e.name == "1") {
        this.thItem = [
          "提现订单号",
          "提现到账类型",
          "银行名称",
          "银行卡号",
          "用户手机",
          "提现总额",
          "申请金额",
          "申请手续费",
          '代付结果',
          '失败原因'
        ];
        this.$refs.needFn.getNeedList(
          this.valueType,
          0,
          this.startDate,
          this.endDate
        );
      } else if (e.name == "2") {
        this.thItem = [
          "提现订单号",
          "提现到账类型",
          "银行名称",
          "银行卡号",
          "用户手机",
          "提现总额",
          "申请金额",
          "申请手续费",
          '代付结果',
          '失败原因'
        ];
        // this.thItem=['合作商类型','合作商名称','提现时间','提现金额','审批时间','手续费','提现到账金额','提现银行','银行卡号']
        this.$refs.passFn.getNeedList(
          this.valueType,
          1,
          this.startDate,
          this.endDate
        );
      } else {
        this.thItem = [
          "提现订单号",
          "提现到账类型",
          "银行名称",
          "银行卡号",
          "用户手机",
          "提现总额",
          "申请金额",
          "申请手续费",
          '代付结果',
          '失败原因'
        ];
        // this.thItem=['合作商类型','合作商名称','提现时间','提现金额','提现银行','银行卡号','审批时间']
        this.$refs.notFn.getNeedList(
          this.valueType,
          2,
          this.startDate,
          this.endDate
        );
      }
    },

    // 删除按钮
    toDel(id) {
      this.$confirm("确定删除该小区吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$http.post("/api/root/Estate/del", { id }).then((res) => {
            console.log(res, "删除结果");
            if (res.code == 1) {
              this.getEstateList();
              this.$message.success("删除成功");
            } else {
              this.$message.warning(res.msg);
            }
          });
        })
        .catch(() => {
          console.log("点击取消");
        });
    },

    // 选择时间
    selectTime() {
      this.startDate = this.valueTime
        ? this.$moment(this.valueTime[0]).format("yyyy-MM-DD")
        : "";
      this.endDate = this.valueTime
        ? this.$moment(this.valueTime[1]).format("yyyy-MM-DD")
        : "";
      if (this.activeName == "1") {
        this.$refs.needFn.getNeedList(
          this.valueType,
          0,
          this.startDate,
          this.endDate
        );
      } else if (this.activeName == "2") {
        this.$refs.passFn.getNeedList(
          this.valueType,
          1,
          this.startDate,
          this.endDate
        );
      } else {
        this.$refs.notFn.getNeedList(
          this.valueTypee,
          2,
          this.startDate,
          this.endDate
        );
      }
    },

    // 搜索
    handerSeach() {
      if (this.activeName == "1") {
        this.$refs.needFn.getNeedList(
          this.valueType,
          0,
          this.startDate,
          this.endDate
        );
      } else if (this.activeName == "2") {
        this.$refs.passFn.getNeedList(
          this.valueType,
          1,
          this.startDate,
          this.endDate
        );
      } else {
        this.$refs.notFn.getNeedList(
          this.valueType,
          2,
          this.startDate,
          this.endDate
        );
      }
    },

    // 详情按钮
    toEdit(id) {
      this.$router.push({ name: "estateAdd", query: { id } });
    },

    // 状态选择
    statusSelectFn(e) {
      console.log(e, "状态选择");
      this.getInfoList();
    },

    // 新增资讯按钮
    addRecommend() {
      this.$router.push({ name: "estateAdd", query: {} });
    },

    // 多选
    handlerCheckbox(i) {
      console.log(i);
      let arr = this.checkBoxAll;
      if (arr.includes(i)) {
        let index = arr.indexOf(i);
        if (index != -1) {
          arr.splice(index, 1);
          this.shelvesAlls.splice(index, 1);
          if (this.checkBoxAll.length !== this.tableList.length) {
            this.checkAll = false;
          }
        }
      } else {
        this.checkBoxAll.push(i);
        this.shelvesAlls.push(this.tableList[i].id);
        if (this.checkBoxAll.length == this.tableList.length) {
          this.checkAll = true;
        }
      }
      console.log(this.shelvesAlls);
    },
    // 全选与全不选
    handerCheckAll() {
      this.checkAll = !this.checkAll;
      let arr = this.tableList.length;
      this.checkBoxAll = [];
      this.shelvesAlls = [];
      if (this.checkAll) {
        for (let i = 0; i < arr; i++) {
          this.checkBoxAll.push(i);
        }
        this.checkBoxAll.map((v) => {
          this.shelvesAlls.push(this.tableList[v].id.toString());
        });
      } else {
        this.checkBoxAll = [];
        this.shelvesAlls = [];
      }
      console.log(this.shelvesAlls);
    },

    // // 全选后的删除
    // selectDel(){
    // 	console.log(this.shelvesAlls);
    // 	let res =[...new Set(this.shelvesAlls)]; //去重
    // 	console.log(res);
    // 	let str = res.join(',');
    // 	if(this.shelvesAlls.length){
    // 		this.$confirm('此操作将删除选中项, 是否继续?', '提示', {
    // 			confirmButtonText: '确定',
    // 			cancelButtonText: '取消',
    // 			type: 'warning'
    // 		}).then(()=>{
    // 			this.$http.post('/api/root/designer/del',{id:str}).then(res=>{
    // 				console.log(res);
    // 				if(res.code==1){
    // 					this.getDesigList();
    // 					this.checkAll=false;
    // 					this.checkBoxAll=[];
    // 					this.shelvesAlls=[];
    // 					this.$message({
    // 						type:'success',
    // 						message:'删除成功'
    // 					})
    // 				}
    // 			})
    // 		})
    // 	}else{
    // 		this.$message({
    // 			type:'info',
    // 			message:'请选择要删除的项'
    // 		})
    // 	}
    // },

    handleSizeChange(val) {
      this.pageSize = val;
      this.getEstateList();
    },
    handleCurrentChange(val) {
      this.page = val;
      this.getEstateList();
    },
  },
};
</script>

<style lang="less" scoped>
@import "index.less";
.el-tabs__item {
  width: 200px;
}
</style>
